/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Figures;

import java.awt.Point;
import java.util.ArrayList;

/**
 *
 * @author Macias
 */
public class Pawn extends Figures{

int white;
    public Pawn(boolean isWh,Point loc){
        isWhite = isWh;
        location=loc;
        if(isWhite) white = 1; else white =0; //conversion boolean to int
    }

    @Override
 public ArrayList<Point> checkPossibleMoves(char [][] board) {
     ArrayList<Point> possibleMoves = new ArrayList();

     if(isWhite){

         if(location.y == 6) {
             if(board[location.x][location.y-2]=='0' && board[location.x][location.y-1]=='0') possibleMoves.add(new Point(location.x,location.y-2));
         }
         if((location.y-1)>=0){
             if(board[location.x][location.y-1]=='0') possibleMoves.add(new Point(location.x,location.y-1));

             if((location.x-1)>=0)
                if(board[location.x-1][location.y-1]>97 && board[location.x-1][location.y-1]<122) possibleMoves.add(new Point(location.x-1,location.y-1));
             if((location.x+1)<=7)
                if(board[location.x+1][location.y-1]>97 && board[location.x+1][location.y-1]<122) possibleMoves.add(new Point(location.x+1,location.y-1));
         }
     }
     else{
         if(location.y == 1) {
             if(board[location.x][location.y+2]=='0' && board[location.x][location.y+1]=='0') possibleMoves.add(new Point(location.x,location.y+2));
         }
         if((location.y+1)<=7){
             if(board[location.x][location.y+1]=='0') possibleMoves.add(new Point(location.x,location.y+1));

             if((location.x-1)>=0)
                 if(board[location.x-1][location.y+1]>65 && board[location.x-1][location.y+1]<90) possibleMoves.add(new Point(location.x-1,location.y+1));
             if((location.x+1)<=7)
                if(board[location.x+1][location.y+1]>65 && board[location.x+1][location.y+1]<90) possibleMoves.add(new Point(location.x+1,location.y+1));
        }
     }

     return possibleMoves;
 }

    @Override
    public int getType(){
        if(isWhite) return 80;
        else return 112;

    }

}
